package cn.kailangtu.dataspot.activify;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.SystemClock;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.navigation.fragment.NavHostFragment;

import com.example.ipcamstream.IpCamStream;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.formatter.ValueFormatter;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.litepal.LitePal;

import java.io.File;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.List;
import java.util.Random;

import cn.kailangtu.commonevents.eventEntity.BluetoothConnectChangedEvent;
import cn.kailangtu.commonevents.eventEntity.DataBeanChangedEvent;
import cn.kailangtu.commonevents.eventEntity.EthernetConnectChangedEvent;
import cn.kailangtu.commonevents.eventEntity.FragmentChangedEvent;
import cn.kailangtu.commonevents.eventEntity.MobileConnectChangedEvent;
import cn.kailangtu.commonevents.eventEntity.OnFragmentChangeEvent;
import cn.kailangtu.commonevents.eventEntity.OpenCameraViewEvent;
import cn.kailangtu.commonevents.eventEntity.RealViewCloseEvent;
import cn.kailangtu.commonevents.eventEntity.RealViewOpenEvent;
import cn.kailangtu.commonevents.eventEntity.SystemErrCodeEvent;
import cn.kailangtu.commonevents.eventEntity.TemperatureDataEvent;
import cn.kailangtu.commonevents.eventEntity.TotalMainDataChangedEvent;
import cn.kailangtu.commonevents.eventEntity.UsbConnectChangedEvent;
import cn.kailangtu.commonevents.eventEntity.WifiConnectChangedEvent;
import cn.kailangtu.commontools.APPSPUtils;
import cn.kailangtu.commontools.AppUtils;
import cn.kailangtu.commontools.AppVariable;
import cn.kailangtu.commontools.DataUtils;
import cn.kailangtu.commontools.DateTimeUtils;
import cn.kailangtu.commontools.LineChatUtils;
import cn.kailangtu.dataspot.R;
import cn.kailangtu.dataspot.camera.AvcPlayerHelper;
import cn.kailangtu.dataspot.data.BaseData;
import cn.kailangtu.dataspot.data.ControlTree;
import cn.kailangtu.dataspot.data.HighData;
import cn.kailangtu.dataspot.data.PageIndex;
import cn.kailangtu.dataspot.data.consts.ControlAction;
import cn.kailangtu.dataspot.data.context.SelectContext;
import cn.kailangtu.dataspot.data.status.ConnectStatus;
import cn.kailangtu.dataspot.databinding.FragmentRealPictureBinding;
import cn.kailangtu.dataspot.db.OptionLogEntity;
import cn.kailangtu.dataspot.db.SwitchLogEntity;
import cn.kailangtu.dataspot.status;
import cn.kailangtu.dataspot.tasks.BaseTask;
import cn.kailangtu.dataspot.total.RealViewTotalData;
import cn.kailangtu.dataspot.total.TotalData;
import com.github.mikephil.charting.components.Description;

public class RealPictureFragment extends BaseFragment {

    private FragmentRealPictureBinding binding;
    private BaseData data = new BaseData();
    String urlRTSP1 = "rtsp://"+ APPSPUtils.getInstance().getCameraIp()+":8554/profile0";
    private boolean isRun = true;
    private IpCamStream ipCamStream;
    private IpCamStream.cameraOnFrameListen cameraOnFrameListen;


    private Handler autoScrollHandler = new Handler();
    private  final long AUTO_SCROLL_DELAY = 2000; // 2秒



    @Override
    public View onCreateView(
            @NonNull LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState
    ) {

       // binding = FragmentRealPictureBinding.inflate(inflater, container, false);
        binding = FragmentRealPictureBinding.inflate(inflater, container, false);
        return binding.getRoot();

    }

    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        realViewTotalData =new RealViewTotalData(binding.lineChartDianYa,binding.lineChartDianliu);

        resetElement();
        resetData();
        initListen();
        EventBus.getDefault().post(new FragmentChangedEvent(R.layout.fragment_real_picture));


        binding.tvSN.setText(AppUtils.getInstance().getAndroidSN());

        String strLocalIp = AppUtils.getInstance().getIpAddress();
        String strVpnIp = AppUtils.getInstance().getVpnIpAddress();
        if(!strLocalIp.isEmpty() && !strLocalIp.equals("0.0.0.0"))
        {
            binding.tvLocalIP.setText("内网:"+strLocalIp);
            binding.tvLocalIP.setVisibility(View.VISIBLE);
        }
        else{
            binding.tvLocalIP.setVisibility(View.GONE);
        }
        if(!strVpnIp.isEmpty())
        {
            binding.tvCloundIP.setText("外网:"+strVpnIp);
            binding.tvCloundIP.setVisibility(View.VISIBLE);
        }
        else
        {
            binding.tvCloundIP.setVisibility(View.GONE);
        }



        new Thread(new Runnable() {
            @Override
            public void run() {
                while(isRun) {
                    RealPictureFragment.this.getActivity().runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if(binding != null && binding.tvRealPictureTime != null) {
                                binding.tvRealPictureTime.setText(DateTimeUtils.nowYMDHMS());
                            }
                        }
                    });

                    SystemClock.sleep(1000);
                }
            }
        }).start();

       //  initCamera();
       // initIPCameraView1();

        // testLineChat();

        binding.lineChartDianYa.setNoDataText("");
        binding.lineChartDianliu.setNoDataText("");


        new Thread(new Runnable() {
            @Override
            public void run() {
                int index = 0;
                while(index < 10) {
                    TotalData.totalSecond(10, 1, 0);
                    index++;
                    SystemClock.sleep(1000);
                    Log.d("IOIOIUOIUIUIUIU","做了");

                }
            }
        }).start();

        initIPCameraView1();

    }
    DecimalFormat df = new DecimalFormat("#.#");


    private void resetData()
    {
        data.getVoltageA().setValue(HighData.getInstance().getValue(3506));
        data.getVoltageB().setValue(HighData.getInstance().getValue(3507));
        data.getVoltageC().setValue(HighData.getInstance().getValue(3508));

        data.getElectricA().setValue(HighData.getInstance().getValue(3509));
        data.getElectricB().setValue(HighData.getInstance().getValue(3510));
        data.getElectricC().setValue(HighData.getInstance().getValue(3511));

        data.getCommontTempurature().setValue(HighData.getInstance().getValue(3512));

        data.getElectricCount().setValue(HighData.getInstance().getValue(3515));
        data.getSwitchRunTime().setValue(HighData.getInstance().getValue(3513));
        data.getOpeningCount().setValue(HighData.getInstance().getValue(3514));
        data.getRatedVoltage().setValue(formatRated(HighData.getInstance().getValue(4500)));
        data.getOverloadCurrent().setValue(HighData.getInstance().getValue(4501));
        data.getRatedCurrent().setValue(Math.toIntExact(Math.round(data.getOverloadCurrent().getValue().intValue() * 1.2)));
        data.getShortCircuitCurrent().setValue(HighData.getInstance().getValue(4504)* data.getOverloadCurrent().getValue() / 10);

        data.getRunStatus().setValue(HighData.getInstance().getValue(3503));




        int add_3504 = HighData.getInstance().getValue(3504);
        if(add_3504 == 1)
        {

            binding.iv3504Open.setVisibility(View.GONE);
            binding.iv3504Close.setVisibility(View.VISIBLE);
            binding.btn3504.setText("合 闸");



        }
        else if(add_3504 == 0) {

            binding.iv3504Open.setVisibility(View.VISIBLE);
            binding.iv3504Close.setVisibility(View.GONE);
            binding.btn3504.setText("分 闸");
        }



        binding.tvElectricALable.setText(data.getElectricA().getLabel());
        binding.tvElectricAValue.setText(data.getElectricA().getValue()+"A");
        binding.tvVoltageALable.setText(data.getVoltageA().getLabel());
        binding.tvVoltageAValue.setText(data.getVoltageA().getValue()+"V");

        binding.tvElectricBLable.setText(data.getElectricB().getLabel());
        binding.tvElectricBValue.setText(data.getElectricB().getValue()+"A");
        binding.tvVoltageBLable.setText(data.getVoltageB().getLabel());
        binding.tvVoltageBValue.setText(data.getVoltageB().getValue()+"V");


        binding.tvElectricCLable.setText(data.getElectricC().getLabel());
        binding.tvElectricCValue.setText(data.getElectricC().getValue()+"A");
        binding.tvVoltageCLable.setText(data.getVoltageC().getLabel());
        binding.tvVoltageCValue.setText(data.getVoltageC().getValue()+"V");

        binding.tvRealPictureEA1.setText("Ia:"+
                data.getElectricA().getValue() +"A"
        );

        binding.tvRealPictureEA2.setText("Ib:"+
                data.getElectricB().getValue() +"A"
        );

        binding.tvRealPictureEA3.setText("Ic:"+
                data.getElectricB().getValue()
                +"A"
        );

        binding.tvRealPictureVA.setText("系统电压:"
                +(data.getVoltageA().getValue() + data.getVoltageB().getValue()+ data.getVoltageC().getValue()) / 3
                +"V"
        );

        binding.tvRealPictureTemper.setText("温度:"+data.getCommontTempurature().getValue()+"°C");

        binding.tvCommontTempuratureLable.setText(data.getCommontTempurature().getLabel());
        binding.tvCommontTempuratureValue.setText(data.getCommontTempurature().getValue()+"°C");

        binding.tvSwitchRunTimeLable.setText(data.getSwitchRunTime().getLabel());
        binding.tvSwitchRunTimeValue.setText(data.getSwitchRunTime().getValue()+"h");


        binding.tvopeningCountLable.setText(data.getOpeningCount().getLabel());
        binding.tvopeningCountValue.setText(data.getOpeningCount().getValue()+"次");

        binding.tvRatedVoltageLable.setText(data.getRatedVoltage().getLabel());
        binding.tvRatedVoltageValue.setText(data.getRatedVoltage().getValue()+"V");

        binding.tvOverloadCurrentLabel.setText(data.getOverloadCurrent().getLabel());
        binding.tvOverloadCurrentValue.setText(data.getOverloadCurrent().getValue()+"A");

        binding.tvRatedCurrentLable.setText(data.getRatedCurrent().getLabel());
        binding.tvRatedCurrentValue.setText(data.getRatedCurrent().getValue()+"A");
        binding.tvShortCircuitCurrentLabel.setText(data.getShortCircuitCurrent().getLabel());
        binding.tvShortCircuitCurrentValue.setText(data.getShortCircuitCurrent().getValue()+"A");

        binding.tvRunStatusLabel.setText(data.getRunStatus().getLabel());
        binding.tvRunStatusValue.setText(BaseData.getRunStatusHigh( data.getRunStatus().getValue()));

        binding.tvMatherLineTempuratureLable.setText(data.getMatherLineTempurature().getLabel());
        binding.tvMatherLineTempuratureValue.setText(data.getMatherLineTempurature().getValue()+"°C");
        binding.tvMatherLineTempuratureValue2.setText(data.getMatherLineTempurature().getValue2()+"°C");
        binding.tvMatherLineTempuratureValue3.setText(data.getMatherLineTempurature().getValue3()+"°C");

        binding.tvMatherLineTempuratureValue.setText(df.format(status.temp_3584)+"°C");
        binding.tvMatherLineTempuratureValue2.setText(df.format(status.temp_3585)+"°C");
        binding.tvMatherLineTempuratureValue3.setText(df.format(status.temp_3586)+"°C");

        binding.tvOutLineTempuratureLable.setText(data.getOutLineTempurature().getLabel());
        binding.tvOutLineTempuratureValue.setText(data.getOutLineTempurature().getValue()+"°C");
        binding.tvOutLineTempuratureValue2.setText(data.getOutLineTempurature().getValue2()+"°C");
        binding.tvOutLineTempuratureValue3.setText(data.getOutLineTempurature().getValue3()+"°C");

        binding.tvOutLineTempuratureValue.setText(df.format(status.temp_3587)+"°C");
        binding.tvOutLineTempuratureValue2.setText(df.format(status.temp_3588)+"°C");
        binding.tvOutLineTempuratureValue3.setText(df.format(status.temp_3589)+"°C");

    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
        isRun = false;
        avcPlayerHelper.close();

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(WifiConnectChangedEvent event)
    {
        if(ConnectStatus.isWifiConnected())
        {
            binding.ivRealPictureWIFI.setImageResource(R.drawable.element_realpicture_top_wifi_used);
        }
        else{
            binding.ivRealPictureWIFI.setImageResource(R.drawable.element_realpicture_top_wifi);
        }

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(UsbConnectChangedEvent event)
    {
        if(ConnectStatus.isUsbConnected())
        {
            binding.ivRealPictureUSB.setImageResource(R.drawable.element_realpicture_top_usb_used);
        }
        else{
            binding.ivRealPictureUSB.setImageResource(R.drawable.element_realpicture_top_usb);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(MobileConnectChangedEvent event)
    {
        if(ConnectStatus.isMobileConnected())
        {
            binding.ivRealPictureMOBILE.setImageResource(R.drawable.element_realpicture_top_tower_used);
        }
        else{
            binding.ivRealPictureMOBILE.setImageResource(R.drawable.element_realpicture_top_tower);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(EthernetConnectChangedEvent event)
    {
        if(ConnectStatus.isEthernetConnected())
        {
            binding.ivRealPictureETHERNET.setImageResource(R.drawable.element_realpicture_top_cross_used);
        }
        else{
            binding.ivRealPictureETHERNET.setImageResource(R.drawable.element_realpicture_top_cross);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(BluetoothConnectChangedEvent event)
    {
        if(ConnectStatus.isBluetoothConnected())
        {
            binding.ivRealPictureBLUETOOTH.setImageResource(R.drawable.element_realpicture_top_bluetooth_used);
        }
        else{
            binding.ivRealPictureBLUETOOTH.setImageResource(R.drawable.element_realpicture_top_bluetooth);
        }
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(DataBeanChangedEvent event){
        resetData();
    }

    private int formatRated(int source)
    {
        if(source == 0)
        {
            return 6000;
        }else if(source == 1)
        {
            return 10000;
        }
        return source;
    }



    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(OnFragmentChangeEvent event) {
        // Do something
        if(R.layout.fragment_factory_setting == event.getTargetFragmentId())
        {
            isRun = false;
            NavHostFragment.findNavController(RealPictureFragment.this)
                    .navigate(R.id.action_RealPictureFragment_to_FactorySettingFragment);
        }
        else if(R.layout.fragment_switch_test == event.getTargetFragmentId())
        {
            isRun = false;
            NavHostFragment.findNavController(RealPictureFragment.this)
                    .navigate(R.id.action_RealPictureFragment_to_SwitchTestFragment);
        }
        else if(R.layout.fragment_common_setting == event.getTargetFragmentId())
        {
            isRun = false;
            NavHostFragment.findNavController(RealPictureFragment.this)
                    .navigate(R.id.action_RealPictureFragment_to_CommonSettingFragment);
        }
        else if(R.layout.fragment_exception_log == event.getTargetFragmentId())
        {
            isRun = false;
            NavHostFragment.findNavController(RealPictureFragment.this)
                    .navigate(R.id.action_RealPictureFragment_to_ExceptionLogFragment);
        }
        else if(R.layout.fragment_real_picture == event.getTargetFragmentId())
        {

        }
    }

    private void initListen(){

    }

    @Override
    protected void resetPageIndex() {

        if (status.localToPlc != 2) {
            status.localPageIndex = PageIndex.H_MAIN;
            BaseTask.toNewPage(status.localPageIndex);
        }
        else
        {
            if(status.plcPageIndex == PageIndex.H_MAIN){
                status.localPageIndex = PageIndex.H_MAIN;
            }
        }
    }

    @Override
    void resetPlatform() {
        if(AppVariable.platform_version == 450 && AppVariable.need_reset_view)
        {
            int top = -20;
            int left = 0;

            ViewGroup.MarginLayoutParams layoutParams =  (ViewGroup.MarginLayoutParams)binding.llRealPictureContainer.getLayoutParams();
            int newtop =  layoutParams.topMargin + top;
            int newleft = layoutParams.leftMargin + left;


            layoutParams.setMargins(newleft,newtop,0,0);
            binding.llRealPictureContainer.setLayoutParams(layoutParams);


        }
    }


    private void showCamera(){
        EventBus.getDefault().post(new OpenCameraViewEvent());
    }


    @Override
    protected int processControlsEvent(int eventType) {
        if(eventType == ControlAction.Selection)
        {
            TextView textView =  this.getActivity().findViewById(controlTree.getSelectNode().getIndex());
            SelectContext.setSelectedView(textView);
        }
        else if(eventType == ControlAction.Entry){
            openKeybaord();
        }
        return 0;
    }

    @Override
    protected void buildControlTree() {
        controlTree = ControlTree.getDataControlTree();
        controlTree.setSelectNode(null);
    }





    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(RealViewOpenEvent event){

        avcPlayerHelper.pause(true);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(RealViewCloseEvent event){
        avcPlayerHelper.pause(false);
    }




    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(TemperatureDataEvent event){
        DecimalFormat df = new DecimalFormat("#.#");
        Log.d("SHOOTLEE_TEMP","JJJ"+event.getIndex());
        if (event.getIndex() == 0) {
            Log.d("SHOOTLEE_TEMP","JJJ00");
            binding.apSub.setImageBitmap(event.getImage());
            binding.ivRealViewHighH.setText("腔内最高温度:"+ df.format(status.temp_3584)+"°C");
            binding.ivRealViewLowH.setText("腔内最低温度:"+df.format(status.temp_3587)+"°C");
            binding.ivRealViewAvgH.setText("腔内平均温度:"+df.format(status.temp_avg_1)+"°C");
            Log.d("SHOOTLEE_TEMP","JJJ0000");
        } else if (event.getIndex() == 1) {
            Log.d("SHOOTLEE_TEMP","JJJ11");
            binding.apSub.setImageBitmap(event.getImage());
            binding.ivRealViewHighH.setText("腔内最高温度:"+df.format(status.temp_3585)+"°C");
            binding.ivRealViewLowH.setText("腔内最低温度:"+df.format(status.temp_3588)+"°C");
            binding.ivRealViewAvgH.setText("腔内平均温度:"+df.format(status.temp_avg_2)+"°C");
            Log.d("SHOOTLEE_TEMP","JJJ1111");
        } else if (event.getIndex() == 2) {
            Log.d("SHOOTLEE_TEMP","JJJ22");
            binding.apSub.setImageBitmap(event.getImage());
            binding.ivRealViewHighH.setText("腔内最高温度:"+df.format(status.temp_3586)+"°C");
            binding.ivRealViewLowH.setText("腔内最低温度:"+df.format(status.temp_3589)+"°C");
            binding.ivRealViewAvgH.setText("腔内平均温度:"+df.format(status.temp_avg_3)+"°C");
            Log.d("SHOOTLEE_TEMP","JJJ2222");
        }

    }

    AvcPlayerHelper avcPlayerHelper = new AvcPlayerHelper();

    private void initIPCameraView1(){
        avcPlayerHelper.initIPCameraView(binding.apMain);
    }



    int lastValue = 0;
    String lastTime = "";
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(SystemErrCodeEvent event){
        if(lastValue != event.getCurrentCode())
        {
            lastValue = event.getCurrentCode();
            lastTime = APPSPUtils.getInstance().getLastErrTime();
            if(lastTime.isEmpty()) {
                lastTime = DateTimeUtils.longToYMDHMS(System.currentTimeMillis());
                APPSPUtils.getInstance().putLastErrTime(lastTime);
            }

        }
        if(event.getCurrentCode() > 1)
        {
            binding.rlMainErr.setVisibility(View.VISIBLE);
            binding.tvMainErrContent.setText( event.getErrMsg());
            binding.tvMainErrTime.setText(lastTime);
            binding.tvMainErrTitle.setText(event.getErrTitle());
        }
        else
        {
            binding.rlMainErr.setVisibility(View.GONE);
            binding.tvMainErrContent.setText( "");
            binding.tvMainErrTime.setText("");
            binding.tvMainErrTitle.setText("");
            lastTime = "";
            APPSPUtils.getInstance().putLastErrTime("");
        }
    }



    RealViewTotalData realViewTotalData = null;

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(TotalMainDataChangedEvent event){

        if(realViewTotalData != null){
            realViewTotalData.resetData(event);
        }
    }





    private void resetElement()
    {
        if(APPSPUtils.getInstance().get红外测温视频Switch().equals("开"))
        {



            //lineChat变zai
            ViewGroup.LayoutParams layoutParamsDianliu =  binding.lineChartDianliu.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsDianYa = binding.lineChartDianYa.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsMiddle = binding.llMiddle.getLayoutParams();
            binding.llRight.setVisibility(View.VISIBLE);

            layoutParamsDianliu.width = 500;
            layoutParamsDianYa.width = 500;

            layoutParamsMiddle.width = 540;


//            if(status.hasTemperature)
//            {
//                ViewGroup.LayoutParams layoutParamsChatContainer = binding.rlChatContainer.getLayoutParams();
//                layoutParamsChatContainer.height = 380;
//                binding.rlChatContainer.setLayoutParams(layoutParamsChatContainer);
//                binding.rlMatherContainer.setVisibility(View.GONE);
//            }
//            else
//            {
//                binding.rlMatherContainer.setVisibility(View.GONE);
//            }

            ViewGroup.LayoutParams layoutParamsVA = binding.tvRealPictureVA.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsEA1 =  binding.tvRealPictureEA1.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsEA2 = binding.tvRealPictureEA2.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsEA3 = binding.tvRealPictureEA3.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsTemper =   binding.tvRealPictureTemper.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsLine1 = binding.vLine1.getLayoutParams();
            ViewGroup.LayoutParams layoutParamsLine2 =  binding.vLine2.getLayoutParams();

            binding.tvRealPictureVA.setTextSize(18f);
            binding.tvRealPictureEA1.setTextSize(18f);
            binding.tvRealPictureEA2.setTextSize(18f);
            binding.tvRealPictureEA3.setTextSize(18f);
            binding.tvRealPictureTemper.setTextSize(18f);


            layoutParamsVA.width = 150;
            layoutParamsEA1.width = 80;
            layoutParamsEA2.width = 80;
            layoutParamsEA3.width = 80;
            layoutParamsTemper.width = 120;
            layoutParamsLine1.width = 500;
            layoutParamsLine2.width = 500;
            binding.tvRealPictureVA.setLayoutParams(layoutParamsVA);
            binding.tvRealPictureEA1.setLayoutParams(layoutParamsEA1);
            binding.tvRealPictureEA2.setLayoutParams(layoutParamsEA2);
            binding.tvRealPictureEA3.setLayoutParams(layoutParamsEA3);
            binding.tvRealPictureTemper.setLayoutParams(layoutParamsTemper);
            binding.vLine1.setLayoutParams(layoutParamsLine1);
            binding.vLine2.setLayoutParams(layoutParamsLine2);



            binding.lineChartDianliu.setLayoutParams(layoutParamsDianliu);
            binding.lineChartDianYa.setLayoutParams(layoutParamsDianYa);

            binding.llMiddle.setLayoutParams(layoutParamsMiddle);

            realViewTotalData.resetParams();
        }
    }
}